Skip to content

Add Cmd+Arrow tab navigation in panel#351

Open
robinebers wants to merge 2 commits intomainfrom
robinebers/cmd-arrow-tabs
Open

Add Cmd+Arrow tab navigation in panel#351
robinebers wants to merge 2 commits intomainfrom
robinebers/cmd-arrow-tabs

Conversation

@robinebers
Copy link
Copy Markdown
Owner

@robinebers robinebers commented Apr 7, 2026

Description

Add Cmd+Up / Cmd+Down navigation for the open panel so the user can switch between Home and enabled provider tabs without reordering anything.
The shortcut works immediately after opening from either the tray icon or the global shortcut because the panel now reclaims focus when it becomes visible.
The cycle wraps at the ends and skips Settings, and the change is covered with focused panel and app regression tests.

Related Issue

N/A

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev
  • Ran bunx vitest run src/hooks/app/use-panel.test.ts src/App.test.tsx

Screenshots

Keyboard-only change; no screenshot attached.

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Note

Low Risk
Mostly adds client-side keyboard/focus handling with comprehensive tests; low risk aside from potential UX regressions from globally listening to keydown and changing focus behavior.

Overview
Adds Cmd+ArrowUp/ArrowDown keyboard navigation to cycle the panel sidebar between home and provider views (wrapping at ends), while skipping settings and ignoring key events originating from editable elements.

Ensures the shortcut works immediately after the panel is shown by making the panel container focusable (tabIndex={-1}) and auto-focusing it on window focus/visibility regain and after tray navigation/about events. Updates and expands hook/app tests to cover focus behavior and view-cycling edge cases.

Reviewed by Cursor Bugbot for commit 0d6e0ed. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Add Cmd+Up/Down navigation to switch between Home and provider tabs in the panel. The panel now reclaims focus on window focus/visibility and after tray/about actions so the shortcut works immediately.

  • New Features

    • Cmd+Up/Down cycles through Home and enabled provider tabs; wraps at ends and skips Settings.
    • Auto-focus on window focus and visibility change, and after tray navigation/about; AppShell container is focusable (tabIndex={-1}).
    • Shortcut is ignored when typing in inputs or contenteditable areas; tests added for navigation, focus, and editable targets.
  • Refactors

    • Consolidated focus logic into a single helper used by window, visibility, and tray listeners.

Written for commit 0d6e0ed. Summary will update on new commits.

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 7, 2026

🤖 Augment PR Summary

Summary: Adds Cmd+Up / Cmd+Down navigation to cycle between Home and enabled provider tabs in the panel.

Changes:

  • Make the panel container programmatically focusable via tabIndex=-1 so it can reclaim focus on show.
  • In usePanel, refocus the container on window focus / visibility restoration, and after tray-driven navigation/about events.
  • Add Cmd+Arrow key handling to compute the next view (wraps at ends, skips Settings) and update activeView.
  • Ignore Cmd+Arrow navigation when the event target is an editable control (inputs/contenteditable/role=textbox).
  • Tighten usePanel typing by switching displayPlugins from unknown[] to DisplayPluginState[].
  • Add focused regression tests for Cmd+Arrow navigation and focus recovery in use-panel and the full App.

Technical Notes: Key handling is attached at the window level and uses Meta-only (Cmd) with ArrowUp/ArrowDown; focus restoration is deferred via requestAnimationFrame.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8cfe6a9. Configure here.

@validatedev validatedev requested a review from Copilot April 7, 2026 20:20
@validatedev
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Cmd+ArrowUp/ArrowDown keyboard navigation for the panel’s sidebar to cycle between Home and enabled provider views (wrapping at ends and skipping Settings), and updates focus handling so the shortcut works immediately after the panel becomes visible. Includes new hook-level and app-level regression tests covering navigation and focus behavior.

Changes:

  • Add Cmd+ArrowUp/ArrowDown key handling in usePanel to cycle views (Home + enabled providers), skipping Settings and ignoring editable targets.
  • Add “reclaim focus” behavior (window focus + visibility change + tray events) and make the panel container programmatically focusable via tabIndex={-1}.
  • Add/extend unit and integration tests for navigation, editable-target ignoring, settings skipping, and focus regain.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/hooks/app/use-panel.ts Implements Cmd+Arrow navigation and focus-reclaim behavior; updates types for displayPlugins.
src/hooks/app/use-panel.test.ts Adds focused unit tests for view cycling, editable target ignoring, settings skip, and focus regain.
src/components/app/app-shell.tsx Makes the panel container focusable (tabIndex={-1}) to support programmatic focus.
src/App.test.tsx Adds an app-level regression test verifying Cmd+Up/Down tab switching after focus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +57
const focusContainer = useCallback(() => {
window.requestAnimationFrame(() => {
containerRef.current?.focus({ preventScroll: true })
})
}, [])

useEffect(() => {
const handleVisibilityChange = () => {
if (!document.hidden) {
focusContainer()
}
}

window.addEventListener("focus", focusContainer)
document.addEventListener("visibilitychange", handleVisibilityChange)
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new focus reclaim logic always focuses containerRef on window focus / tab visibility. This will steal focus from any currently focused element inside the panel (e.g. the Global Shortcut recorder uses a focused div[role="textbox"] and cancels recording on blur), causing UX regressions.

Consider only focusing the container when focus is currently outside the panel (e.g. if containerRef.current does not contain document.activeElement), or when document.activeElement is body/null. This preserves existing in-panel focus while still ensuring the panel becomes keyboard-active when first shown.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants